<?php 
include '../function.php';

$data = current($_FILES);

if(!$data){
	echo "上传文件失败";exit;
}

if($data['error']>0){
	switch ($data['error']) {
		case '1':
			echo "上传的文件超过了 php.ini 中 upload_max_filesize 选项限制的值:错误代码：".$data['error'];
			break;
		case '2':
			echo "上传文件的大小超过了 HTML 表单中 MAX_FILE_SIZE 选项指定的:错误代码：".$data['error'];
			break;
		case '3':
			echo "文件只有部分被上传:错误代码：".$data['error'];
			break;
		default:
			echo "系统未知错误：错误代码：".$data['error'];
			break;
	}
	exit;
}

$maxSize = 400000;

if($data['size']>$maxSize){
	echo "文件大小超限制：限制大小为：".$maxSize;
	exit;
}

$suffixs = array('jpg','png','gif');

$arr = explode('.', $data['name']);

$suffix = end($arr);

if(!in_array($suffix, $suffixs)){
	echo "文件上传的类型不符合,要求的上传类型是：".implode(',', $suffixs);exit;

}

$path = "./Upload/".date('Y-m-d');

is_dir($path) || mkdir($path);


$name = uniqid();

move_uploaded_file($data['tmp_name'],$path.'/'.$name.".".$suffix);


// move_uploaded_file($data['tmp_name'],$path.'/'.$data['name']);
echo "上传成功";

















 ?>